---
title: Nginx
description: Deploy Kaneo with Nginx as a reverse proxy
---
import { Step, Steps } from 'fumadocs-ui/components/steps';

This guide explains how to deploy Kaneo using Nginx as a reverse proxy. This setup is ideal for production environments where you want to expose Kaneo through a domain name with HTTPS.

## Prerequisites

- A server with Docker and Docker Compose installed
- A domain name pointing to your server
- Basic knowledge of Nginx configuration

<Steps>
<Step>
Create a `compose.yml` file with the following content:
</Step>

```yaml
services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: kaneo
      POSTGRES_USER: kaneo_user
      POSTGRES_PASSWORD: kaneo_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: unless-stopped

  backend:
    image: ghcr.io/usekaneo/api:latest
    environment:
      JWT_ACCESS: "your_secure_jwt_token"
      DATABASE_URL: "postgresql://kaneo_user:kaneo_password@postgres:5432/kaneo"
    ports:
      - "1337:1337"
    depends_on:
      - postgres
    restart: unless-stopped

  frontend:
    image: ghcr.io/usekaneo/web:latest
    environment:
      KANEO_API_URL: "http://localhost:1337"
    ports:
      - "5173:5173"
    depends_on:
      - backend
    restart: unless-stopped

volumes:
  postgres_data:
```

<Step>
Create a `nginx.conf` file with the following content in `/etc/nginx/sites-available/kaneo.conf`:
</Step>

```nginx
server {
  listen 80;
  server_name your-domain.com;

  location / {
    proxy_pass http://localhost:5173;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

server {
  listen 80;
  server_name api.your-domain.com;

  location / {
    proxy_pass http://localhost:1337;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
```

<Step>
Start the containers:

```bash
docker compose up -d
```
</Step>

<Step>
Enable the configuration:

```bash
sudo ln -s /etc/nginx/sites-available/kaneo.conf /etc/nginx/sites-enabled/
```
</Step>

<Step>
Test the configuration:

```bash
sudo nginx -t
```
</Step>

<Step>
Restart Nginx:

```bash
sudo systemctl restart nginx
```
</Step>

<Step>
Configure your DNS settings to point both `your-domain.com` and `api.your-domain.com` to your server's IP address.
</Step>

<Step>
You should now be able to access Kaneo at `http://your-domain.com` and the API at `http://api.your-domain.com`. 🎉
</Step>
</Steps>

## Alternative Configuration: Single Domain with Path-Based Routing

If you prefer to use a single domain with path-based routing, you can use the following configuration:

<Steps>
<Step>
Create a `compose.yml` file with the following content:
</Step>

```yaml
services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: kaneo
      POSTGRES_USER: kaneo_user
      POSTGRES_PASSWORD: kaneo_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: unless-stopped

  backend:
    image: ghcr.io/usekaneo/api:latest
    environment:
      JWT_ACCESS: "your_secure_jwt_token"
      DATABASE_URL: "postgresql://kaneo_user:kaneo_password@postgres:5432/kaneo"
    ports:
      - "1337:1337"
    depends_on:
      - postgres
    restart: unless-stopped

  frontend:
    image: ghcr.io/usekaneo/web:latest
    environment:
      KANEO_API_URL: "http://your-domain.com/api"
    ports:
      - "5173:5173"
    depends_on:
      - backend
    restart: unless-stopped

volumes:
  postgres_data:
```

<Step>
Create a `nginx.conf` file with the following content in `/etc/nginx/sites-available/kaneo.conf`:
</Step>

```nginx
server {
  listen 80;
  server_name your-domain.com;

  location / {
    proxy_pass http://localhost:5173;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location /api/ {
    proxy_pass http://localhost:1337/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
```

<Step>
Start the containers:

```bash
docker compose up -d
```
</Step>

<Step>
Enable the configuration:

```bash
sudo ln -s /etc/nginx/sites-available/kaneo.conf /etc/nginx/sites-enabled/
```
</Step>

<Step>
Test the configuration:

```bash
sudo nginx -t
```
</Step>

<Step>
Restart Nginx:

```bash
sudo systemctl restart nginx
```
</Step>

<Step>
Configure your DNS settings to point `your-domain.com` to your server's IP address.
</Step>

<Step>
You should now be able to access Kaneo at `http://your-domain.com` and the API will be accessible at `http://your-domain.com/api`. ��
</Step>
</Steps>
